var dateFormatStr = function (date) {
  var date = new Date(Date.parse(date.replace(/-/g, "/")));
  var newDate = new Date();
  var year = date.getFullYear()
  var month = date.getMonth() + 1
  var day = date.getDate()
  var hour = date.getHours()
  var minute = date.getMinutes()
  var second = date.getSeconds()
  if (newDate.getTime() > date.getTime()) {
    //时间间隔
    var timeLag = newDate.getTime() - date.getTime()
    //转换成天
    var days = Math.round(timeLag / 86400000)
    //转换成小时
    var hours = Math.round(timeLag / 3600000)
    //转换成分钟
    var mins = Math.round(timeLag / 60000)
    if (days > 1) {
      date = days + '天前'
    } else if (hours > 1) {
      date = hours + '小时前'
    } else if (mins > 1) {
      date = mins + '分钟前'
    } else {
      if (hour < 10) {
        hour = '0' + hour
      }
      if (minute < 10) {
        minute = '0' + minute
      }
      if (second < 10) {
        second = '0' + second
      }
      date = hour + ":" + minute + ":" + second
    }
  }
  return date
}
var timeFormat = function (date) {
  var date = new Date(Date.parse(date.replace(/-/g, "/")));
  // // wxs写法
  // date = getDate(date)
  var hour = date.getHours()
  var minute = date.getMinutes()
  if (hour < 10) {
    hour = '0' + hour
  }
  if (minute < 10) {
    minute = '0' + minute
  }
  date = hour + ":" + minute
  return date
}
var moneyFormat = function (money) {
  return money.toFixed(2);
}

/*
 * 导出
 */
module.exports = {
  dateFormatStr: dateFormatStr,
  moneyFormat: moneyFormat,
  timeFormat: timeFormat
}